
{extend name='table'}

{block name="content"}
<div class="layui-card padding-20 shadow layui-card-body" >
    <table id="CustomerAmountTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
</div>
{/block}
{block name='script'}
<script>
    $(function () {
        // 初始化表格组件
        $('#CustomerAmountTable').layTable({
            even: true,
            page:false,
            where: {customer_id: '{$customer_id}'},
            sort: {field: 'id desc', type: 'desc'},
            cols: [[
                {title: '序号', type: 'numbers', width: 60},
                {field: 'power_source', title: '陪玩名称', align: "center", minWidth: 170},
                {field: 'prestore_amount', title: '预存金额', align: "center", minWidth: 170,edit: 'text'},
                {field: 'use_amount', title: '已用金额', align: 'center', minWidth: 140,edit: 'text'}
            ]]

        });
        // 单元格编辑事件
        layui.table.on('edit(CustomerAmountTable)', function(obj){
            var field = obj.field; // 得到修改的字段
            var value = obj.value // 得到修改后的值
            var data = obj.data // 得到所在行所有键
            console.log(obj); // 查看对象所有成员
            $.form.load("{:url('edit')}",data, 'post', function (ret) {
                if (ret.code < 1) $.msg.error(ret.info, 3, function () {
                    $('#CustomerAmountTable').trigger('reload');
                }); else {
                    $('#CustomerAmountTable').trigger('reload')
                }
                return false;
            })

        });


    });

</script>

{/block}







